﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Infragistics.Controls.Menus;

namespace StartupSolution.Views.Menus.Selection
{
    public partial class XamOutlookBarCodeBehindSelection : Page
    {
        public XamOutlookBarCodeBehindSelection()
        {
            InitializeComponent();

            Loaded += new RoutedEventHandler(XamOutlokkBarXamlSelection_Loaded);
        }

        void XamOutlokkBarXamlSelection_Loaded(object sender, RoutedEventArgs e)
        {

            // Create a XamOutlookBar control
            XamOutlookBar outlookBar = new XamOutlookBar();

            // Set the XamOutlookBar control Width, MinimizedWidth, HorizontalAlignment properties.
            outlookBar.Width = 250;
            outlookBar.Height = 400;
            outlookBar.MinimizedWidth = 40;
            outlookBar.HorizontalAlignment = HorizontalAlignment.Left;

            outlookBar.ReserveSpaceForLargeImage = false;

            // Create an OutlookBarGroup with a header and images
            OutlookBarGroup mailGroup = new OutlookBarGroup();
            mailGroup.Header = "Mail";
            mailGroup.Content = "Mail Group Content";
            outlookBar.Groups.Add(mailGroup);

            OutlookBarGroup calendarGroup = new OutlookBarGroup();
            calendarGroup.Header = "Calendar";
            calendarGroup.Content = "Calendar Group Content";
            outlookBar.Groups.Add(calendarGroup);

            // Attach handler for the SelectedGroupChanged event
            outlookBar.SelectedGroupChanged += new System.EventHandler<SelectedGroupChangedEventArgs>(outlookBar_SelectedGroupChanged);

            // Add the XamOutlookBar control to the container grid LayoutRoot
            LayoutRoot.Children.Add(outlookBar);
            Grid.SetRow(outlookBar, 2);
        }

        void  outlookBar_SelectedGroupChanged(object sender, SelectedGroupChangedEventArgs e)
        {
            // TODO: Implement your custom logic to handle the XamOutlookBar control SelectedGroupChanged event  

            if (e.PreviousSelectedOutlookBarGroup != null)
            {
                MessageBox.Show("Previous selected group: " + e.PreviousSelectedOutlookBarGroup.Header + " | New selected group: " + e.NewSelectedOutlookBarGroup.Header);
            }
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {

        }
    }
}
